package cn.eeepay.framework.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import cn.eeepay.framework.model.AgentAuthorizedOpenRecord;

public interface AgentAuthorizedOpenRecordMapper {

	@Select("select * from  agent_authorized_open_record ")
	List<AgentAuthorizedOpenRecord> listAll();

	@Delete("delete from agent_authorized_open_record where id=#{id}")
	int deleteById(Integer id);

	@Select("select count(*) from  agent_authorized_open_record where agent_link = #{agentLink} or agent_authorized= #{agentLink}")
	long countByAgentLink(String agentLink);

	@Delete({"DELETE  ",// 
			"FROM ",// 
			"	agent_authorized_open_record  ",// 
			"WHERE ", // 
			"	agent_link IN ( SELECT agent_link FROM agent_authorized_link WHERE agent_node LIKE concat( #{agentLink}, '%' ) )"})
	int deleteByAgentNode(String agentLink);

	@Insert("insert into agent_authorized_open_record (agent_link,agent_authorized,create_time) values(#{agentLink},#{agentAuthorized},#{createTime})")
	int insert(AgentAuthorizedOpenRecord agentAuthorizedOpenRecord);

}
